package com.example.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.example.test.bean.GW;
import com.example.test.bean.TW;
import com.example.test.util.ToastUtil;

public class TWActivity extends AppCompatActivity {
    private EditText carNumber_2,date_2,w_2;
    private MySQLiteOpenHelper_2 mySQLiteOpenHelper_2;
    String CarNumber_2,Date_2,W_2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tw);
        initView();
        mySQLiteOpenHelper_2 = new MySQLiteOpenHelper_2(this);
    }
    private void initView(){
        carNumber_2 = findViewById(R.id.carNumber);
        date_2 = findViewById(R.id.date_1);
        w_2 = findViewById(R.id.w_1);
    }
    public void tw_btn(View view){
        CarNumber_2 = carNumber_2.getText().toString();
        Date_2 = date_2.getText().toString();
        W_2 = w_2.getText().toString();

        TW tw =new TW();
        tw.setCarNumber_2(CarNumber_2);
        tw.setDate_2(Date_2);
        tw.setW_2(W_2);

        long rowId =mySQLiteOpenHelper_2.insertData(tw);
        if(rowId !=-1){
            ToastUtil.toastShort(this,"添加成功");
        }else {
            ToastUtil.toastShort(this,"添加失败");

        }
    }
}